{% extends "layout.html" %}
{% load rbac %}
{% block css %}
    <style>
        tr.active {
            border-left: 3px solid #fdc00f;
        }
    </style>
{% endblock %}
{% block content %}
    <div class="mobiledj-container">
        <div class="col-md-3">
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">
                    <i class="fa fa-book" aria-hidden="true"></i>一级菜单
                    <a class="right btn btn-success btn-xs" style="padding: 2px 8px; margin: -3px;"
                       href="{% memory_url request 'rbac:menu_add' %}"
                       style=" margin: -3px;">
                        <i class="fa fa-plus-square" aria-hidden="true"></i> 新建
                    </a>
                </div>
                <!-- Table -->
                <table class="table">
                    <thead>
                    <tr>
                        <th>名称</th>
                        <th>图标</th>
                        <th>选项</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for row in menus %}
                        <tr class="{% if row.id|safe == menu_id %} active {% endif %}">
                            <td><a href="?mid={{ row.id }}">{{ row.title }}</a></td>
                            <td><i class="fa {{ row.icon }}" aria-hidden="true"></i></td>
                            <td><a href="{% memory_url request "rbac:menu_edit" pk=row.id %}">修改</a>|<a
                                    href="{% memory_url request "rbac:menu_del" pk=row.id %}">删除</a></td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="col-md-4">
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">
                    <i class="fa fa-bookmark" aria-hidden="true"></i>二级菜单
                    {% if menu_id %}
                        <a class="right btn btn-success btn-xs" style="padding: 2px 8px; margin: -3px;"
                           href="{% memory_url request 'rbac:second_menu_add' menu_id=menu_id %}"
                           style=" margin: -3px;">
                            <i class="fa fa-plus-square" aria-hidden="true"></i> 新建
                        </a>
                    {% endif %}
                </div>
                <!-- Table -->
                <table class="table">
                    <thead>
                    <tr>
                        <th>名称</th>
                        <th>CODE&URL</th>
                        <th>选项</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for row in second_menu %}
                        <tr class={% if row.id|safe == second_menu_id %}"active" {% endif %}>
                            <td rowspan="2"><a href="?mid={{ menu_id }}&sid={{ row.id }}">{{ row.title }}</a></td>
                            <td>{{ row.name }}</td>
                            <td><a href="{% memory_url request "rbac:second_menu_edit" pk=row.id %}">修改</a>|<a
                                    href="{% memory_url request "rbac:second_menu_del" pk=row.id %}">删除</a></td>
                        </tr>
                        <tr class={% if row.id|safe == second_menu_id %}"active" {% endif %}>
                            <td colspan="2" style="border-top: 0;">{{ row.url }}</td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="col-md-5">
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">
                    <i class="fa fa-bookmark" aria-hidden="true"></i>权限
                    <div style="float: right;">
                        <a class="btn btn-sm btn-primary" style="padding: 2px 8px; margin: -3px;"
                           href="{% memory_url request 'rbac:multi_permission' %}">
                            <i class="fa fa-mail-forward" aria-hidden="true"></i> 批量操作
                        </a>
                    </div>
                    {% if second_menu_id %}
                        <div style="float: right;margin:0 20px;">
                            <a class="btn btn-sm btn-success" style="padding: 2px 8px; margin: -3px;"
                               href="{% memory_url request 'rbac:permission_add' second_menu_id=second_menu_id %}">
                                <i class="fa fa-plus-square" aria-hidden="true"></i> 新建
                            </a>
                        </div>
                    {% endif %}

                </div>
                <!-- Table -->
                <table class="table">
                    <thead>
                    <tr>
                        <th>权限名称</th>
                        <th>CODE&URL</th>
                        <th>选项</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for row in permissions %}
                        <tr>
                            <td rowspan="2">{{ row.title }}</td>
                            <td>{{ row.name }}</td>
                            <td><a href="{% memory_url request 'rbac:permission_edit' pk=row.id %}">修改</a>|<a
                                    href="{% memory_url request 'rbac:permission_del' pk=row.id %}">删除</a></td>
                        </tr>
                        <tr>
                            <td colspan="2" style="border-top: 0;">{{ row.url }}</td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock %}